//
//  UIView+CHYExtension.m
//  百思不得姐
//
//  Created by 崔 on 16/8/1.
//  Copyright © 2016年 崔. All rights reserved.
//

#import "UIView+CHYExtension.h"

@implementation UIView (CHYExtension)

-(void)setChy_size:(CGSize)chy_size{
    
    CGRect frame = self.frame;
    
    frame.size = chy_size;
    
    self.frame = frame;
    
}
- (CGSize)chy_size{
    
    return self.frame.size;
}


-(void)setChy_width:(CGFloat)chy_width{
    
    CGRect frame = self.frame;
    
    frame.size.width = chy_width;
    
    self.frame = frame;
    
}

- (CGFloat)chy_width{
    
    return self.frame.size.width;
}

- (void)setChy_height:(CGFloat)chy_height{
    
    CGRect frame = self.frame;
    
    frame.size.height = chy_height;
    
    self.frame = frame;
    
}

- (CGFloat)chy_height{
    
    return self.frame.size.height;
}

- (void)setChy_x:(CGFloat)chy_x{
    
    CGRect frame = self.frame;
    
    frame.origin.x = chy_x;
    
    self.frame = frame;
}

- (CGFloat)chy_x{
    
    return self.frame.origin.x;
}

- (void)setChy_y:(CGFloat)chy_y{
    
    CGRect frame = self.frame;
    
    frame.origin.y = chy_y;
    
    self.frame = frame;
}

- (CGFloat)chy_y{
    
    return self.frame.origin.y;
}

- (void)setChy_centerX:(CGFloat)chy_centerX{
    
    CGPoint center = self.center;
    
    center.x = chy_centerX;
    
    self.center = center;
}

- (CGFloat)chy_centerX{
    
    return self.center.x;
}

-(void)setChy_centerY:(CGFloat)chy_centerY{
    
    CGPoint center = self.center;
    
    center.x = chy_centerY;
    
    self.center = center;
}

- (CGFloat)chy_centerY{
    
    return self.center.y;
}

- (void)setChy_right:(CGFloat)chy_right{
    
    self.chy_x = chy_right - self.chy_width;
}

- (CGFloat)chy_right{
    
    return CGRectGetMaxX(self.frame);
}

- (void)setChy_bottom:(CGFloat)chy_bottom{
    
    self.chy_y = chy_bottom - self.chy_height;
}

- (CGFloat)chy_bottom{
    
    return CGRectGetMaxY(self.frame);
}

+ (instancetype)CHY_viewFromXib{
    
    
   return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
}
@end
